home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
System Booster
/
System Booster.iso
/
Systemmonitors
/
RSys
/
RSysSrc.lha
/
RSysClip.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-09-19
|
3KB
|
182 lines
/*
***************************************************************************
*
* Datei:
* RSysClip.c
*
* Inhalt:
*
* --- Globale Routinen ---
*
* void RSysEntryToClip ( void );
* void RSysListToClip ( void );
* void SaveListToClip ( struct List *list , char *text );
*
* --- Lokale Routinen ---
*
*
* Bemerkungen:
* Unterstützung des ClipBoard-Devices.
*
* Erstellungsdatum:
* 07-Jul-93 Rolf Böhme
*
* Änderungen:
* 07-Jul-93 Rolf Böhme Erstellung
*
***************************************************************************
*/
#include "RSys.h"
void
SaveListToClip(struct List *list,char *text)
{
char Success = FALSE;
struct Node *node;
int len;
struct IFFHandle *Handle;
DPOS;
if (IFFParseBase = OpenLibrary ((UBYTE *)"iffparse.library", 0L))
{
if(Handle = AllocIFF())
{
if(Handle->iff_Stream = (ULONG)OpenClipboard(PRIMARY_CLIP))
{
InitIFFasClip(Handle);
if(!OpenIFF(Handle,IFFF_WRITE))
{
if(!PushChunk(Handle,ID_FTXT,ID_FORM,IFFSIZE_UNKNOWN))
{
if(!PushChunk(Handle,0,ID_CHRS,IFFSIZE_UNKNOWN))
{
if(list != NULL)
{
for(node = list->lh_Head; node->ln_Succ; node = node->ln_Succ)
{
len = strlen(node->ln_Name);
if(WriteChunkBytes(Handle,node->ln_Name,len) != len) break;
if(WriteChunkBytes(Handle,"\n",1) != 1) break;
}
}
else
{
len = strlen(text);
if(WriteChunkBytes(Handle,(STRPTR)text,len) != len) Success = FALSE;
}
if(!PopChunk(Handle)) Success = TRUE;
}
}
if(Success)
if(PopChunk(Handle)) Success = FALSE;
CloseIFF(Handle);
}
CloseClipboard((struct ClipboardHandle *)Handle->iff_Stream);
}
FreeIFF(Handle);
}
CloseLibrary (IFFParseBase);
}
else ErrorHandle("iffparse.library", LIBRARY_ERR, OPEN_FAIL, NO_KILL);
if(!Success) ErrorHandle("Unit 0", CLIPBOARD_ERR, WRITE_FAIL, NO_KILL);
return;
}
void
RSysListToClip(void)
{
HandleHelp(MN_RSysListToClip);
PrintInfo("Saving List to clipboard", SPEAK, 0);
SaveListToClip(&ListeLVList, NULL);
PrintStatistics();
return;
}
void
RSysEntryToClip(void)
{
register struct IntuiMessage *message;
APTR object;
ULONG class,
code;
DPOS;
HandleHelp(MN_RSysEntryToClip);
Flags.quit_clip = 0;
PrintInfo("Select list entry (ESC to cancel)", SPEAK, 0);
do
{
/*
* Warten auf folgende Events:
* - ^C wurde eingegeben
* - Events vom Hauptfenster
*/
Wait(1L << SysWnd->UserPort->mp_SigBit);
while ((message = (struct IntuiMessage *) GT_GetIMsg(SysWnd->UserPort)) != NULL)
{
/*
* Die wichtigsten Daten werden aus der erhaltenen
* Nachricht kopiert.
*/
object = message->IAddress;
class = message->Class;
code = message->Code;
/*
* Die Nachricht wird sofort beantwortet, damit
* Intuition nicht länger als notwendig auf eine
* Antwort wartet.
*/
GT_ReplyIMsg(message);
if(class == IDCMP_GADGETUP)
{
if(((struct Gadget *)object)->GadgetID == GD_ListeLV)
{
struct Node *node;
if(node = GetNode(&ListeLVList,code))
{
SaveListToClip(NULL, node->ln_Name);
Flags.quit_clip = 1;
}
}
}
if((class == IDCMP_VANILLAKEY) && (code == ESC))
{
Flags.quit_clip = 1;
PrintInfo("Selection aborted!",SPEAK, SEC);
}
}
} while(NOT(Flags.quit_clip));
PrintStatistics();
return;
}